package com.video.netty.send;

import com.video.commons.sendaop.ISocketSend;
import com.video.commons.utils.GroupUtil;
import com.video.netty.commons.utils.ChannelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 终端分组
 * web发送 groupName组名（每一组由终端+子组构成，所有组名不能重名）； levels子组深度,分组层数最多的（group深度）； grouplevel + 宝安中学 表示组名， userlevel + 宝安中学 表示终端id，和"grouplevel宝安中学"是同一级别
 *
 * {"id": "terminalGroup","groups": [
 *                {"gname": "默认分组","level": 1,"clients": ["1", "2", "3"],
 * 			"groups": [{"gname": "分组1","level": 2,"clients": [],
 * 				"groups": [{"gname": "分组2","level": 3,"clients": ["4"],"groups": []}
 * 				]}
 * 		]}
 * 		, {"gname": "分组4","level": 1,"clients": ["4"],"groups": []}
 * ]}
 *
 * 返回
 *  {"id":"terminalGroupResponse","response":"success"}
 *  {"id":"terminalGroupResponse","response":"fail"}
 */
@Component
public class TerminalGroupSend extends ISocketSend {

    @Autowired
    private GroupUtil groupUtil;

    @Autowired
    private ChannelUtil channelUtil;

    @Override
    public Map<String, Object> sendMsg(Object... objs) {
        String groupInfo = groupUtil.getGroupInfo();
        channelUtil.sendMsg(groupInfo);
        return null;
    }
}
